package com.jiang.test;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.DelayQueue;
import java.util.concurrent.TimeUnit;

import com.jiang.vo.Member;

public class DelayQueueTest1 {

	public static void main(String[] args) {
		
		BlockingQueue<Member> queue = new DelayQueue<Member>();
		try {
			queue.put(new Member("jzw",3,TimeUnit.SECONDS));
			queue.put(new Member("jzc",5,TimeUnit.SECONDS));
			while(!queue.isEmpty()) {
				Member m = queue.poll(); // 没有获取到数据就阻塞
				if(m!=null)
				System.out.println(m);
			}
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	
		
	}

}
